<script>
  import $ from 'dfish-widget'
  import Method from '../Method.vue'

  export default {
    mixins: [Method],
    data() {
      return {
        name: '$.ajax(setting)',
        remark: '发送ajax请求',
        attrs: [{
          name: 'setting',
          remark: 'AJAX 请求设置',
          type: 'Object',
          attrs: [{
              name: 'complete(response)',
              remark: '请求完成后触发。不论请求成功失败都会执行',
              type: 'Function',
            },
            {
              name: 'data',
              remark: 'post发送的数据',
              type: 'Object',
            },
            {
              name: 'error(exception)',
              remark: '请求数据失败时触发',
              type: 'Function',
            },
            {
              name: 'filter(response)',
              remark: '过滤函数。需要 return 数据对象',
              type: 'Function',
            },
            {
              name: 'src',
              remark: '请求地址',
              type: 'Function',
            },
            {
              name: 'success(data)',
              remark: '请求数据成功加载后触发',
              type: 'Function',
            },
          ]
        }],
        examples: [{
          remark: '发送Ajax请求',
          code: `
          $.ajax({
            src: 'get.sp?id=001',
            success(data) {
              console.log(data)
            }
          })`
        }]
      }
    }
  }
</script>
